using System;
using System.Drawing;

using Game.World;
using Game.Input;
using Game.Output;

namespace Game.Utils
{
	public static class CCoordConverter
	{
		public static void Initialize()
		{
			CConsole.ReportClassInit(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name);
		}
		
		public static Point GetTileCoords(Point p_screenCoords, ref CCountry p_country)
		{
			Point s = p_screenCoords;
			
			Point o = new Point();
			o.X = p_country.Position.X + p_country.Origin.X; 
			o.Y = p_country.Position.Y + p_country.Origin.Y;
			
			Point tileCoords = new Point(
				(int)((s.X + 2 * s.Y - o.X - 2 * o.Y) / 64.0f),
				(int)((o.X + 32 * ((s.X + 2 * s.Y - o.X - 2 * o.Y) / 64.0f) - s.X) / 32.0f)
			);
			
			return tileCoords;
		}
		
//		public static Point GetScreenCoords(Point p_tileCoords, Size p_spriteSize)
//		{
//			Point screenCoords = new Point();
//			
//			screenCoords = new Point(
//				32 + CTiles.PosOnScreen.X + CTiles.OriginPos.X + tileCoords.X * 32 - tileCoords.Y * 32 - spriteSize.Width,
//				31 + CTiles.PosOnScreen.Y + CTiles.OriginPos.Y + tileCoords.X * 16 + tileCoords.Y * 16 - spriteSize.Height
//			);
//			
//			return screenCoords;		
//		}
		
	}
}
